﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcShop.Models.ViewDataModels
{
    public class HelperViewData
    {
        #region ==== Property =====
        public int PageIndex { get; set; }
        public int Count { get; set; }
        public int Total { get; set; }
        public string KeyWord { get; set; }

        public Helper Helper { get; set; }
        public IEnumerable<Helper> Helpers { get; set; }

        public HelpCategory HelpCategory { get; set; }
        public IEnumerable<HelpCategory> HelpCategories { get; set; }

        public IEnumerable<HelpList> HelpList { get; set; }
        public IEnumerable<DHelpList> DHelpList { get; set; }
        #endregion

        #region ==== Methods ====
        public HelperViewData WithPageIndex(int pageIndex)
        {
            this.PageIndex = pageIndex;
            return this;
        }

        public HelperViewData WithCount(int count)
        {
            this.Count = count;
            return this;
        }

        public HelperViewData WithTotal(int pageSize)
        {
            this.Total = Math.Max((this.Count + pageSize - 1) / pageSize, 1); ;
            return this;
        }

        public HelperViewData WithKeyWord(string keyWord)
        {
            this.KeyWord = keyWord;
            return this;
        }

        public HelperViewData WithHelper(Helper helper) 
        {
            this.Helper = helper;
            return this;
        }

        public HelperViewData WithHelpers(IEnumerable<Helper> helpers)
        {
            this.Helpers = helpers;
            return this;
        }

        public HelperViewData WithHelpCategory(HelpCategory helpCategory)
        {
            this.HelpCategory = this.HelpCategory;
            return this;
        }

        public HelperViewData WithHelpCategories(IEnumerable<HelpCategory> helpCategories)
        {
            this.HelpCategories = helpCategories;
            return this;
        }

        public HelperViewData WithHelpList(IEnumerable<HelpList> helpList)
        {
            this.HelpList = helpList;
            return this;
        }

        public HelperViewData WithDHelpList(IEnumerable<DHelpList> dHelpList)
        {
            this.DHelpList = dHelpList;
            return this;
        }
        #endregion
    }

    public static class HelperView
    {
        public static HelperViewData Data { get { return new HelperViewData(); } }
    }
}
